<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   template="/WEB-INF/templates/default.xhtml"
   xmlns:p="http://primefaces.org/ui">
   
   <ui:define name="content">
      <h1>Welcome to JBoss AS 7!</h1>

      <p>You have successfully deployed a Java EE 6 web application
         on JBoss AS 7.</p>

      <h:form id="reg">
         <h2>Register (Bean Validation example)</h2>
         <p>Enforces annotation-based constraints defined on the
            model class.</p>
             <h:panelGrid id="grid" columns="3">  
		        <h:outputText value="Pseudo : *" />  
		        <p:inputText id="nickname" required="true" value="#{newMember.nickname}"/>  
		        <p:message id="message-name" for="nickname" display="text"/>  
		  
		        <h:outputText value="Email: *" />  
		        <p:inputText id="email" required="true" value="#{newMember.email}"/>
		        <p:message id="message-email" for="email" display="text" />

				<h:outputLabel for="pwd1" value="Mot de passe : *" />
				<p:password id="pwd1" value="#{newMember.password}"
					feedback="true" match="pwd2" label="Password 1" required="true"/>
				<p:message id="message-pwd1" for="pwd1" display="text" />
					
				<h:outputLabel for="pwd2" value="Confirmation : *" />  
            	<p:password id="pwd2" value="#{newMember.password}" 
            		feedback="false" label="Password 2" required="true"/>  
            	<p:message id="message-pwd2" for="pwd2" display="text" />
            
		    </h:panelGrid>  
		    
		    <p:commandButton id="register" value="Register" update="grid, table" actionListener="#{memberRegistration.register}"/>  
		     
		    <p:messages id="messages" showDetail="true" autoUpdate="true" globalOnly="true"/>
            
      </h:form>
      <h2>Members</h2>
      <h:panelGroup rendered="#{empty members}">
         <em>No registered members.</em>
      </h:panelGroup>
      <h:dataTable id="table" var="_member" value="#{members}"
         rendered="#{not empty members}">
         <h:column>
            <f:facet name="header">Id</f:facet>
                #{_member.id}
            </h:column>
         <h:column>
            <f:facet name="header">Name</f:facet>
                #{_member.nickname}
            </h:column>
         <h:column>
            <f:facet name="header">Email</f:facet>
                #{_member.email}
            </h:column>
         <h:column>
            <f:facet name="header">REST URL</f:facet>
            <a href="#{request.contextPath}/rest/members/#{_member.id}">/rest/members/#{_member.id}</a>
         </h:column>
         <f:facet name="footer">
                REST URL for all members: <a
               href="#{request.contextPath}/rest/members">/rest/members</a>
         </f:facet>
      </h:dataTable>
   </ui:define>
</ui:composition>
